package net.zhengxinyun.performance.App.appCtrl;

import net.zhengxinyun.performance.App.dto.IndexUserDTO;
import net.zhengxinyun.performance.Util.DateUtils;
import net.zhengxinyun.performance.Util.StringUtils;
import net.zhengxinyun.performance.core.Result;
import net.zhengxinyun.performance.core.ResultUtils;
import net.zhengxinyun.performance.data.UserAppDTO;
import net.zhengxinyun.performance.entity.DepartClassHead;
import net.zhengxinyun.performance.service.departClass.DepartHeadService;
import net.zhengxinyun.performance.service.yearSummaryScore.YearSummaryScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * 绩效考核 （年度绩效考核得分）
 */
@RestController
@RequestMapping("/app/deprtScore")
public class ScoreCtrl extends BaseCtrl {

    @Autowired
    private DepartHeadService headService;
    @Autowired
    private YearSummaryScoreService yearSummaryScoreService;

    @PostMapping("/score")
    public Result<HashMap<String, Object>> cityIndexHome(@RequestBody IndexUserDTO filter) {
        HashMap<String, Object> dataMap = new HashMap<>();
        String currentYear = getCurrentYear();
        List<DepartClassHead> heads = headService.queryByDatetime(currentYear);
        if (StringUtils.isBlank(filter.getDateTime())) {
            filter.setDateTime(DateUtils.getLastMonth(currentYear));
        }
        HashMap<String, Object> departScore = yearSummaryScoreService.getDepartScore(heads, filter.getDateTime(), filter.getDepartcode(), null,null);

        System.out.println("-------接口： /deprtScore/score");
        return ResultUtils.getResults(Result.Status.SUCCESS, "获取年度绩效得分成功", departScore);
    }

}
